#include<iostream>

using namespace std;

void dfs(int row ,int col ,int len,int x,int y )
{

	len/=2;
	if(len==0)
	{
		return ;
	}
	int a=row+len;
	int b=col+len;
	if(x>=a&&y>=b)
	{
		cout<<a-1<<" "<<b-1<<" "<<4<<endl;
		dfs(row,col,len,a-1,b-1);//1
		dfs(row,b,len,a-1,b);//2
		dfs(a,col,len,a,b-1);//3
		dfs(a,b,len,x,y);////4
	}
	else if(x>=a&&y<b)
	{
		cout<<a-1<<" "<<b<<" "<<3<<endl;
		dfs(row,col,len,a-1,b-1);
		dfs(row,b,len,a-1,b);
		dfs(a,col,len,x,y);////3
		dfs(a,b,len,a,b);
	}
	else if(x<a&&y>=b)
	{
		cout<<a<<" "<<b-1<<" "<<2<<endl;
		dfs(row,col,len,a-1,b-1);//1
		dfs(row,b,len,x,y);////2
		dfs(a,col,len,a,b-1);//3
		dfs(a,b,len,a,b);//4
	}
	else
	{
		cout<<a<<" "<<b<<" "<<1<<endl;
		dfs(row,col,len,x,y);
		dfs(row,b,len,a-1,b);
		dfs(a,col,len,a,b-1);//3
		dfs(a,b,len,a,b);//4
	}
}
int main()
{
	int k,x,y;cin>>k>>x>>y;

	k=(1<<k);

	dfs(1,1,k,x,y);
}